<?php

namespace app\api\model;

use think\Model;

/**
 * 用户模型
 */
class HomeMuser extends Model {
	/**
	 * 用户注册
	 * @param $data 
	*/
	public function register($data)
	{
		$res=$this->where([
			'account'=>$data['account'],
			'user_type'=>$data['user_type'],
		])->find();
		if ($res) return false;
        return $this->insert($data);
	}
	/**
	 * 用户登录
	 * @param $data 
	*/
	public function login($data)
	{
        return $this->where($data)->find();
	}

	/**
	 * 用户信息
	 * @param $data 
	*/
	public function info($id)
	{
        return $this->where('id',$id)->field(
        'id,account,help_count,help_minues,longitude,dimensionality,name,age,avatar_image,mark,habitability,release_req,good_reput,user_type,exchan_coin')->find();
	}

	/**
	 * 修改用户信息
	 */
	public function reset($id,$data) 
	{	
		return $this->where('id',$id)->update($data);
	}


	public function list($data) {
		if (empty($data)) {
			return $this->field(
        'id,name,avatar_image,longitude,dimensionality')->select();
		}else{
			return $this->where('name','like',$data)->field(
        'id,name,avatar_image,longitude,dimensionality')->select();
		}
        
	}
}
